<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
request.setCharacterEncoding("UTF-8");
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 <base href="<%=basePath%>">
<title>合作伙伴配置</title>

<jsp:include page="/WEB-INF/jsp/common/common.jsp"></jsp:include>
<link rel="stylesheet" href="<%=path%>/css/zTreeStyle/zTreeStyle.css">
<script type="text/javascript" src="<%=path%>/js/jquery.ztree.core-3.5.js"></script>
<script type="text/javascript" src="<%=path%>/js/jquery.ztree.excheck-3.5.js"></script>
<script src="<%=path%>/js/jquery.divbox.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
	history.forward();
	$(document).ready(function() {
		isReadyIframe();
		queryChannelInfo(1);
		<%-- added by guozizhou@20150409 for bei jing code begin --%>
		//查询企业类型数据
		$("#oneLevelOrgProperty").change(function(){
			  var parentCode = $("#oneLevelOrgProperty").val();
			  var text = $('#oneLevelOrgProperty').find("option:selected").text();
			  //填充子下拉框orgProperty
			  loadSubDropDownList('unit_type',parentCode,'orgProperty',text);
			});
		$("#oneLevelTradeCode").change(function(){
			  var parentCode = $("#oneLevelTradeCode").val();
			  var text = $('#oneLevelTradeCode').find("option:selected").text();
			  //填充子下拉框tradeCode
			  loadSubDropDownList('industry_type',parentCode,'tradeCode',text);
			});
		$("#address1").change(function(){
			  var parentCode = $("#address1").val();
			  //填充子下拉框address2
			  loadAddrDropDownList(parentCode,'address2');
			  $("#address3").find("option").remove();
			  $("#address3").append('<option value="">----请选择----</option>');
			});
		$("#address2").change(function(){
			  var parentCode = $("#address2").val();
			  //填充子下拉框address3
			  loadAddrDropDownList(parentCode,'address3');
			});
		<%-- added by guozizhou@20150409 for bei jing code end --%>
	});
	
	<%-- added by guozizhou@20150409 for bei jing code begin
	//加载市-县-两级数据下拉框
	//subUnitElement --%>
	function loadAddrDropDownList(param,obj){
		$.ajax({
				url : "<%=path%>/channelManage/queryAddrList?",
				type : 'POST',
				async : false,
				dataType:'json',
				data:{parentCode:param
				},
				success : function(appList) {
					if($.validate(appList))  return;
					//业务处理
					//应用下拉框对象
					var appSelect = document.getElementById(obj);
					appSelect.options.length = 0;
					var opt = new Option();
					opt.text = "--请选择--";
					opt.value = "";
					appSelect.add(opt);
					if (appList != null) {
						for (var i = 0; i < appList.length; i++) {
							var option = new Option();
							option.text = appList[i].areaName;
							option.value = appList[i].areaCode;
							option.title = appList[i].areaName;
							appSelect.add(option);
						}
					}
				}
			});
	 }
	//加载子下拉框适用于 企业类型、行业类型
	//subUnitElement
	function loadSubDropDownList(idType,param,obj,text){
		$.ajax({
				url : "<%=path%>/channelManage/querySubElementList?",
				type : 'POST',
				async : false,
				dataType:'json',
				data:{idType:idType,
					parentCode:param
				},
				success : function(appList) {
					if($.validate(appList))  return;
					//业务处理
					//应用下拉框对象
					var appSelect = document.getElementById(obj);
					appSelect.options.length = 0;
					var opt = new Option();
					opt.text = "--请选择--";
					opt.value = "";
					appSelect.add(opt);
					<%-- 对没有二级企业类型的特殊处理 --%>
					if(param=='1154' || param=='1155' || param=='1159')
					{
						var option = new Option();
						option.text = text;
						option.value = param;
						option.title = text;
						appSelect.add(option);
					}
					if (appList != null) {
						for (var i = 0; i < appList.length; i++) {
							var option = new Option();
							option.text = appList[i].codeName;
							option.value = appList[i].code;
							option.title = appList[i].codeName;
							appSelect.add(option);
						}
					}
				}
			});
	 }
	<%-- added by guozizhou@20150409 for bei jing code end --%>
	
	function isReadyIframe(){
		var iframe = $(window.parent.document).find("#iframe").length;
		if(iframe==0){
			window.location.href="<%=basePath%>index.jsp";
		}
	}
	
	//加载deptTree（所属机构）
	function loadDeptTree(){
		$.openLoading();
		
		$.ajax({
			url : "<%=path%>/channelManage/queryBranchDept?"+new Date().getTime(),
			type : 'POST',
			async : true,
			dataType:'json',
			success:function(data){
				
				var setting = {
						check: {
							enable: true,
							chkStyle: "radio",
							radioType: "all"
						},
						data: {
							simpleData: {
								enable: true
							}
						}
					};

					$.fn.zTree.init($("#deptTree"), setting, data);
					
					$("#deptTreeDiv").OpenDiv2();
			},
			complete:function (){
				$.closeLoading();
			}
		});
	}
	
	//点击"确定"（选择所属dept）
	function chooseDept(){
		var deptTree = $.fn.zTree.getZTreeObj("deptTree");
		var depts = deptTree.getCheckedNodes(true);
		
		$("#deptCname_div").val(depts[0].name);
		$("#deptCode_div").val(depts[0].id);
		
		$("#deptTreeDiv").CloseDiv2();
	}
	
	//隐藏deptTree层
	function closeDeptTreeDiv(){
		$("#deptTreeDiv").CloseDiv2();
	}
	
	//点击“查询”
	function queryChannelInfo(pageIndex){
		var channelName = $("#channelName").val();
		var channelCode = $.trim($("#channelCode").val());
		
		$.openLoading();
		//按照条件执行查询操作
		$.ajax({
			url : "<%=path%>/channelManage/queryByCriteria?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:{
				channelName:channelName,
				channelCode:channelCode,
				pageIndex:pageIndex
			},
			dataType:'json',
			success:function(channelInfoPage){
				$.closeLoading();
				
				if($.validate(channelInfoPage))  return;
				
				if(null != channelInfoPage){
					var buttonStr = "<a href='' onClick='viewChannelInfo(this);return false'>编辑</a> <a href='' onClick='deployAppHandle(this);return false'>配置应用</a> <a href='' onClick='deleteChannelInfo(this);return false'>删除</a>";
					var fieldNames = "CHANNEL_CODE,CHANNEL_NAME,DEPT_CNAME,DEPT_CODE@TDH,TRANS_TYPE?[{'1':'界面出单'};{'2':'系统对接'}],CLIENT_NO,TRANS_TYPE@TDH,IS_USERANDPW_VALIDATE@TDH,IS_IP_VALIDATE@TDH,IS_RSA_ENCRYPT@TDH,IS_ASYNC?[{'1':'是'};{'0':'否'};{'':'否'}],IS_AFFERENTPOLNO?[{'1':'是'};{'0':'否'};{'':'否'}]@TDH,IS_THIRD_PLAN@TDH,IS_THIRD_PLAN?[{'1':'是'};{'0':'否'};{'':'否'}]@TDH,UNIFLAG@TDH,ESTIMATE_AMOUT@TDH,ESTIMATE_DES@TDH,TBR_EMAIL@TDH,CHANNEL_SORT@TDH,CHANNEL_FLAG@TDH";					
					var tableContent = creatTable1(fieldNames,channelInfoPage,null,buttonStr);
					var tableObj = $("#channelInfoTable");
					tableObj.find("tbody").remove();
					tableObj.append(tableContent);
					
					var strPage = creatChannelPage(pageIndex,6,channelInfoPage.maxPage,"1");
					var pageDIV = $("#channelInfoPageDIV");
					pageDIV[0].innerHTML="";
					pageDIV.append(strPage);
				}
			}
		});
	}
	
	
	var deptNo = 0;
	var reFlag="";
	//打开生成投保人编码层
	function openCreateNewClientNoDiv(obj,createFlag){
		var channelCode = $(obj).parent('td').parent('tr')[0].childNodes[0].innerHTML;
		var channelName = $(obj).parent('td').parent('tr')[0].childNodes[1].innerHTML;
		deptNo = $(obj).parent('td').parent('tr')[0].childNodes[3].innerHTML;
		if("reCreate" == createFlag){
			reFlag = createFlag;
			$.ajax({
				url : "<%=path%>/channelManage/loadChannelClientNoInfo?"+new Date().getTime(),
				type : 'POST',
				async : false,
				data:{channelCode:channelCode},
				dataType:'json',
				success:function(data){
					if(data.message==undefined){
						$('#socialNo').val(data.socialNo);
						$('#address1').val(data.address1);
						//填充子下拉框address2
						if(null!=data.address1){
							loadAddrDropDownList(data.address1,'address2');
							$("#address3").find("option").remove();
							$("#address3").append('<option value="">----请选择----</option>');
							//$("#address2 option[value ="+data.address2+"]").attr("select","selected"); 
						}
						//填充子下拉框address3
						if(null!=data.address2){
							loadAddrDropDownList(data.address2,'address3');
						}
						if(null!=data.tradeCode){
							$('#oneLevelTradeCode').val(data.tradeCode.substr(0,4));
							var parentCode = $("#oneLevelTradeCode").val();
							var text = $('#oneLevelTradeCode').find("option:selected").text();
							//填充子下拉框tradeCode
							loadSubDropDownList('industry_type',parentCode,'tradeCode',text);
						}
						if(null!=data.orgProperty){
							$('#oneLevelOrgProperty').val(data.orgProperty.substr(0,4));
							var parentCode1 = $("#oneLevelOrgProperty").val();
							var text1 = $('#oneLevelOrgProperty').find("option:selected").text();
							//填充子下拉框orgProperty
							loadSubDropDownList('unit_type',parentCode1,'orgProperty',text1);
						}
						$('#address2').val(data.address2);
						$('#address3').val(data.address3);
						$('#orgProperty').val(data.orgProperty);
						$('#tradeCode').val(data.tradeCode);
						$('#idType').val(data.idType);
						$('#idNo').val(data.idNo);
						$('#city').val(data.city);
						$('#channelNameEn').val(data.channelNameEn);
						$('#corporateDelegate').val(data.corporateDelegate);
						$('#telNo').val(data.telNo);
						$('#faxNo').val(data.faxNo);
						$('#postCode').val(data.postCode);
						$('#address').val(data.address);
						$('#linkManName').val(data.linkManName);
						$('#linkManCertificateType').val(data.linkManCertificateType);
						$('#linkManCertificateNo').val(data.linkManCertificateNo);
						$('#linkManTel').val(data.linkManTel);
						$('#linkManAddress').val(data.linkManAddress);
						$('#linkManPostCode').val(data.linkManPostCode);
						$('#linkManMobileNo').val(data.linkManMobileNo);
					}else{
						$.message("error", "页面加载失败");
					}
				}
			});	
		}
		<%--对北京分行做特殊处理	gzz--%>
		if('11' != deptNo){
			$('#onlyBeiJingBranch,#onlyBeiJingBranch1,#onlyBeiJingBranch2,#onlyBeiJingBranch3,#onlyBeiJingBranch4').hide();
		}else{
			$('#onlyBeiJingBranch,#onlyBeiJingBranch1,#onlyBeiJingBranch2,#onlyBeiJingBranch3,#onlyBeiJingBranch4').show();
		}
		$('#chCode').val(channelCode);
		$('#chName').val(channelName);
		$('#createClientNoDiv').OpenDiv();
		
	}
	
	//重置
	function reset(){
		$('#idType').val(0);
		$('#idNo').val('');
		$('#socialNo').val('');
		$('#orgProperty').val("");
		$('#tradeCode').val("");
		$('#address1').val("");
		$('#address2').val("");
		$('#address3').val("");
		$('#oneLevelTradeCode').val("");
		$('#oneLevelOrgProperty').val("");
		//added by gzz@20151015 for optimize begin
		$('#city').val("");
		$('#channelNameEn').val("");
		$('#corporateDelegate').val("");
		$('#telNo').val("");
		$('#faxNo').val("");
		$('#postCode').val("");
		$('#address').val("");
		$('#linkManName').val("");
		$('#linkManCertificateType').val("");
		$('#linkManCertificateNo').val("");
		$('#linkManTel').val("");
		$('#linkManAddress').val("");
		$('#linkManPostCode').val("");
		$('#linkManMobileNo').val("");
		reFlag="";
	}

	
	//生成投保人编码
	function createNewClientNo(){
		var code = $('#chCode').val();
		var name = $('#chName').val();
		var type = $('#idType').val();
		var num = $.trim($('#idNo').val());
		var socialNo = $('#socialNo').val();
		var orgProperty =$('#orgProperty').val();
		var tradeCode =$('#tradeCode').val();
		var address1 = $('#address1').val();
		var address2 = $('#address2').val();
		var address3 = $('#address3').val();
		var oneLevelOrgProperty = $('#oneLevelOrgProperty').val();
		var oneLevelTradeCode = $('#oneLevelTradeCode').val();
		var city =$('#city').val();
		var channelNameEn =$('#channelNameEn').val();
		var corporateDelegate =$('#corporateDelegate').val();
		var telNo =$('#telNo').val();
		var faxNo =$('#faxNo').val();
		var postCode =$('#postCode').val();
		var address =$('#address').val();
		var linkManName =$('#linkManName').val();
		var linkManCertificateType =$('#linkManCertificateType').val();
		var linkManCertificateNo =$('#linkManCertificateNo').val();
		var linkManTel =$('#linkManTel').val();
		var linkManAddress =$('#linkManAddress').val();
		var linkManPostCode =$('#linkManPostCode').val();
		var linkManMobileNo =$('#linkManMobileNo').val();
		
		if(type==0){
			$.message("error","请选择证件类型");
			return;
		}
		if(num==""){
			$.message("error","请输入证件号码");
			return;
		}
		<%-- added by guozizhou@20150409 for bei jing code begin --%>
		if('11' == deptNo)
		{
			if(socialNo.length == 0){
				$.message("error","请输入社保登记号");
				return;
			}
			if(orgProperty ==""){
				$.message("error","请选择企业性质子类");
				return;
			}
			if(tradeCode == ""){
				$.message("error","请选择行业类型子类");
				return;
			}
			if(address1=="" || address2 =="" || address3 ==""){
					$.message("error","请选择地址信息-省-市-县");
					return;
			}
			if(linkManAddress == ""){
				$.message("error","请输入联系人通讯地址");
				return;
			}
			<%-- added by guozizhou@20150409 for bei jing code end --%>
		}else{
			if(oneLevelOrgProperty !="" && orgProperty ==""){
				$.message("error","请选择企业性质子类");
				return;
			}
			if(oneLevelTradeCode !="" && tradeCode == ""){
				$.message("error","请选择行业类型子类");
				return;
			}
		}
		if(linkManMobileNo.length>0){
			var reg = /^(13[0-9]|15[012356789]|17[0678]|18[0-9]|14[57])[0-9]{8}$/;
			if(!reg.test(linkManMobileNo)){
				$.message("error","联系人手机号格式不正确，请修改");
				return;
			}
		}
		if("reCreate" == reFlag){
			$.dialog({
				type: "warn",//success,error
				content: "投保人编码已生成，您确认重新生成？",
				onOk: function() {
					$.openLoading();
					//按照条件执行查询操作
					$.ajax({
						url : "<%=path%>/channelManage/createClientNo?"+new Date().getTime(),
						type : 'POST',
						async : true,
						data:{
							channelCode:code,
							channelName:name,
							idType:type,
							idNo:num,
							deptNo:deptNo,
							socialNo:socialNo,
							orgProperty:orgProperty,
							tradeCode:tradeCode,
							address1:address1,
							address2:address2,
							address3:address3,
							city:city,
							channelNameEn:channelNameEn,
							corporateDelegate:corporateDelegate,
							telNo:telNo,
							faxNo:faxNo,
							postCode:postCode,
							address:address,
							linkManName:linkManName,
							linkManCertificateType:linkManCertificateType,
							linkManCertificateNo:linkManCertificateNo,
							linkManTel:linkManTel,
							linkManAddress:linkManAddress,
							linkManPostCode:linkManPostCode,
							linkManMobileNo:linkManMobileNo,
							createClientNoFlag:reFlag
						},
						dataType:'json',
						success:function(data){
							$.closeLoading();
							if($.validate(data))  return;
							closeCurrentDIV('createClientNoDiv');
							queryChannelInfo(1);
						}
					});
				}
			});			
		}else{
			$.openLoading();
			//按照条件执行查询操作
			$.ajax({
				url : "<%=path%>/channelManage/createClientNo?"+new Date().getTime(),
				type : 'POST',
				async : true,
				data:{
					channelCode:code,
					channelName:name,
					idType:type,
					idNo:num,
					deptNo:deptNo,
					socialNo:socialNo,
					orgProperty:orgProperty,
					tradeCode:tradeCode,
					address1:address1,
					address2:address2,
					address3:address3,
					city:city,
					channelNameEn:channelNameEn,
					corporateDelegate:corporateDelegate,
					telNo:telNo,
					faxNo:faxNo,
					postCode:postCode,
					address:address,
					linkManName:linkManName,
					linkManCertificateType:linkManCertificateType,
					linkManCertificateNo:linkManCertificateNo,
					linkManTel:linkManTel,
					linkManAddress:linkManAddress,
					linkManPostCode:linkManPostCode,
					linkManMobileNo:linkManMobileNo,
					createClientNoFlag:reFlag
				},
				dataType:'json',
				success:function(data){
					$.closeLoading();
					if($.validate(data))  return;
					closeCurrentDIV('createClientNoDiv');
					queryChannelInfo(1);
				}
			});
		}
	}
	
	//关闭  窗口
	function closeCurrentDIV(obj){
			$("#"+obj).CloseDiv();
			reset();
	}

	//配置应用方法 
	function deployAppHandle(channelInfo){
		//要配置的合作伙伴代码
		var channelCode = $(channelInfo).parent('td').parent('tr')[0].childNodes[0].innerHTML;
		window.location.href='<%=basePath%>channelManage/appDeployHandle?channelCode='+encodeURIComponent(channelCode);
	}
	
	//点击“删除”（channelInfo）
	function deleteChannelInfo(channelInfo){
		//要删除的合作伙伴代码
		var channelCode = $(channelInfo).parent('td').parent('tr')[0].childNodes[0].innerHTML;
		var deptCode = $(channelInfo).parent('td').parent('tr')[0].childNodes[3].innerHTML;
		var channelflag = $(channelInfo).parent('td').parent('tr')[0].childNodes[17].innerHTML;
		if(channelflag=='1'){
			$.message("error","无法删除专有合作伙伴");
			return;
		}
		if(channelCode){
			$.dialog({
				type: "warn",//success,error
				content: "您确定要删除该条记录吗？",
				onOk: function() {
					$.openLoading();
					 $.ajax({
							url : "<%=path%>/channelManage/deleteChannelInfoByChannelCode?"+new Date().getTime(),
							type : 'POST',
							dataType:'json',
							data:{
								channelCode:channelCode,
								deptCode:deptCode
							},
							success : function(data) {
								$.closeLoading();
								
								if($.validate(data))  return;
								
								queryChannelInfo(1);
							}
						});	 
				}
			});
		}
	}
	
	//新增channelInfo时，检查系统中是否已经存在输入的ChannelCode
	var channelCodeFlag = true;
	function checkChannelCode(){
		var channelCode = $("#channelCode_div").val();
		var reg = /^[a-zA-Z0-9_]{1,30}$/;
		if(channelCode!=''){
			if(!reg.test(channelCode)){
				$.message("error", "合作伙伴代码只支持字母数字下划线组合且长度不能大于30");
				return false;
			}
		}
		 $.ajax({
				url : "<%=path%>/channelManage/queryChannelInfoByChannelCode?"+new Date().getTime(),
				type : 'POST',
				async:false,
				dataType:'json',
				data:{
					channelCode:channelCode
				},
				success :  function(data) {
					if(data != null && data.result == "fail"){//错误
						$.message("error", "系统错误");
						
					}else if(data != null){//业务处理
						$.message("error", "该合作伙伴代码已被占用，请更换");
						
						channelCodeFlag = false;
						$("#channelCode_div").focus();
					}else if(data == null){
						channelCodeFlag = true;
					}
				}
			});	 
	}
	
	//合作伙伴“合作方式”改变时动态显示 合作伙伴相关配置
	function channelInfoRelatedDivControl(){
		var transType_div = $("#transType_div").val();
		var channelCode_div=$("#channelCode_div").val();
		var transIp_div=$("#transIp_div").val();
		var transUser_div=$("#transUser_div").val();
		var transRsa_div=$("#transRsa_div").val();
		if(transType_div == 1){
			hideChannelInfoRelatedDiv();
			hideChannelInfoRelatedDiv2();
			$("#transUSer_div").hide();
			$("#transRSA_div").hide();
			$("#transIP_div").hide();
			$("#channelInfoRelated_Key").hide();
		}else if(transType_div == 2){
			$("#channelInfoRelated_Key").hide();
			$("#transUSer_div").show();
			$("#transRSA_div").show();
			$("#transIP_div").show();
			if(transUser_div==1){
				displayChannelInfoRelatedDiv();
			}else{
				hideChannelInfoRelatedDiv();
			}
			if(transIp_div==1){
				displayChannelIpDiv();
			}else{
				hideChannelInfoRelatedDiv2();
			}
			if(transRsa_div==1){
				$("#channelInfoRelated_Key").show();
			}else{
				$("#channelInfoRelated_Key").hide();
			}
			loadChannelUser(); //加载channelUser
			loadChannelIp();  //加载channelIp
		}
	}
	//隐藏 用户密码相关配置
	function hideChannelInfoRelatedDiv(){
		$("#channelInfoRelated_User").css("display","none");
		$("#channelRelatedTable").css("border-bottom","1px solid #bbcddb");
		$("#addOrUpdateDiv").css("height","300px");
		$("#channelRelatedDiv").css("height","280px");
	}
	//隐藏 IP相关配置
	function hideChannelInfoRelatedDiv2(){
		$("#channelInfoRelated_Ip").css("display","none");
		$("#channelRelatedTable").css("border-bottom","1px solid #bbcddb");
		$("#addOrUpdateDiv").css("height","300px");
		$("#channelRelatedDiv").css("height","280px");
	}

	//显示 用户密码相关配置
	function displayChannelInfoRelatedDiv(){
		$("#channelInfoRelated_User").css("display","inline");
		$("#addOrUpdateDiv").css("height","420px");
		$("#channelRelatedDiv").css("height","380px");
	}
	//显示 IP相关配置
	function displayChannelIpDiv(){
		$("#channelInfoRelated_Ip").css("display","inline");
		$("#addOrUpdateDiv").css("height","420px");
		$("#channelRelatedDiv").css("height","380px");
	}
	
	//点击"新增"(弹出层)
	function addChannelInfo(){
		$("#is_async").removeAttr("checked");
		$("#is_afferentpolno").removeAttr("checked");
		$("#channelCode_div").val("");
		$("#channelCode_div").removeAttr("readonly");
		$("#channelCode_div").css("background","#fff");
		$("#channelCode_div").bind("blur",function (){ checkChannelCode() });
		$("#channelCode_div_span").css("display","inline");
		$("#transType_div").val("1");
		$("#is_wxflag").removeAttr("checked");
		$("#channelName_div").removeAttr("readonly");
		$("#deptbtn").removeAttr("disabled");
		$("#channelName_div").css("background","");
		hideChannelInfoRelatedDiv();
		hideChannelInfoRelatedDiv2();
		$("#transUSer_div").hide();
		$("#transRSA_div").hide();
		$("#transIP_div").hide();
		$("#channelInfoRelated_Key").hide();
		$("#addOrUpdateDiv").OpenDiv();
		$("#saveChannelInfoBtn").val("新增");
		
		/* disabledBtn("channelUserBtn"); */
		/* disabledBtn("channelIpBtn"); */
		/* disabledBtn("channelKeyBtns");//lfd */
	}
	
	//点击“保存/更新(channelInfo)”
	function saveOrUpdateChannelInfo(){
		var channelCode_div = $.trim($("#channelCode_div").val());
		var channelName_div = $.trim($("#channelName_div").val());
		var channelsort_div = $.trim($("#channelsort_div").val());
		var deptCode_div = $("#deptCode_div").val();
		var transType_div = $("#transType_div").val();
		var transUser_div = $("#transUser_div").val();
		var transIp_div = $("#transIp_div").val();
		var transRsa_div = $("#transRsa_div").val();
		var tbrEmail_div=$("#tbrEmail_div").val();
		var estimateAmout_div=$('#EstimateAmout_div').val();
		var estimateDes_div=$('#EstimateDes_div').val();
		var isAsync = $("#is_async");
		var is_Async = "";
		if(isAsync.is(":checked")){
			is_Async = "1";
		}else{
			is_Async = "0";
		}
		//是否接口传入保单号 1.是 0.否
		var isAfferentPolno = $("#is_afferentpolno");
		var afferentPolno = "";
		if(isAfferentPolno.is(":checked")){
			afferentPolno = "1";
		}else{
			afferentPolno = "0";
		}
		var PublicKey=$("#PublicKey").val();
		var PrivateKey=$("#PrivateKey").val();
		var CooperatePublicKey=$("#CooperatePublicKey").val();
		
		//判断执行操作是否是”新增“
		var saveChannelInfoBtn = $("#saveChannelInfoBtn").val();
		
		var saveOrUpdate;
		if(saveChannelInfoBtn == "新增"){
			saveOrUpdate = "save";
		}
		if(saveChannelInfoBtn == "更改"){
			saveOrUpdate = "update";
		}
		
		if(saveOrUpdate == "save"){
			if(channelCode_div == ""){
				$.message("error", "请输入合作伙伴代码");
				return;
			}else{
				var reg = /^[a-zA-Z0-9_]{1,30}$/;
				if(!reg.test(channelCode_div)){
					$("#channelCode_div").focus();
					$.message("error", "合作伙伴代码只支持字母数字下划线组合且长度不能大于30");
					return;
				}
			}
			//再次检查系统中是否已经存在输入的ChannelCode
			checkChannelCode();
			if(!channelCodeFlag){
				return;
			}
		}
		
		if(channelName_div=="")
		{
			$.message("error", "请输入合作伙伴名称");
			
			return;
		}else if(channelName_div.length > 50){
			$.message("error", "合作伙伴名称长度不能大于50，请重新输入");
			
			return;
		}
		if(deptCode_div=="")
		{
			$.message("error", "请选择所属机构");
			
			return;
		} 
		
		if(transRsa_div==2){
			PublicKey="";
			PrivateKey="";
			CooperatePublicKey="";
		}
		var isThirdPlan=$('#isThirdPlan_div').val();
		$.openLoading();
		$.ajax({
			url : "<%=path%>/channelManage/saveOrUpdateChannelInfo?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:{
				channelCode:channelCode_div,
				channelName:channelName_div,
				deptCode:deptCode_div,
				transType:transType_div,
				transUser:transUser_div,
				transIp:transIp_div,
				transRsa:transRsa_div,
				flag:saveOrUpdate,
				publicKey:PublicKey,
				privateKey:PrivateKey,
				cooperatePublicKey:CooperatePublicKey,
				is_Async:is_Async,
				afferentPolno:afferentPolno,
				isThirdPlan:isThirdPlan,
				tbrEmail:tbrEmail_div
			},
			dataType:'json',
			success : function(data) {
				$.closeLoading();
				
				if($.validate(data))  return;
				
				//业务处理
				$("#channelCode_div").val(channelCode_div);
				$("#channelName_div").val(channelName_div);
				
				$("#saveChannelInfoBtn").val("更改");

				$("#channelCode_div").attr("readonly","readonly");
				$("#channelCode_div").css("background","#ccc");
				$("#channelCode_div").unbind("blur");
				$("#channelCode_div_span").css("display","none");
				if(transType_div=='2'){
				 	/* enabledBtn("channelUserBtn"); */
					/* enabledBtn("channelIpBtn"); */
					/* enabledBtn("channelKeyBtns");//lfd */
					$("#transUser_div").removeAttr("disabled");
					$("#transIp_div").removeAttr("disabled");
					$("#transRsa_div").removeAttr("disabled");
					$("#transUser_div").removeAttr("disabled");
					$("#transIp_div").removeAttr("disabled");
					$("#transRsa_div").removeAttr("disabled");
				}
				if(transType_div=='1'){
				 /* 	disabledBtn("channelUserBtn"); */
				 	/* disabledBtn("channelIpBtn"); */
				 	/* disabledBtn("channelKeyBtns");//lfd */
				}
				//$("#addOrUpdateDiv").CloseDiv();//关闭层
				
				queryChannelInfo(1);//刷新channelInfo的表格内容
			}
		});
		
	}
	
	//点击“编辑”（channelInfo）
	//var appId_present;记录当前channelInfo所属的app
	function viewChannelInfo(channelInfo){
		
			$("#saveChannelInfoBtnTr").hide();
			var tempTr = $(channelInfo).parent().parent()[0];
			var channelCode= tempTr.childNodes[0].innerHTML;
			var channelName = tempTr.childNodes[1].innerHTML;
			//appId_present = tempTr.childNodes[3].innerHTML;
			var deptCode = tempTr.childNodes[3].innerHTML;
			var deptCname = tempTr.childNodes[2].innerHTML;
			var transType = tempTr.childNodes[6].innerHTML;
			var transUser = tempTr.childNodes[7].innerHTML;
			var transIp = tempTr.childNodes[8].innerHTML;
			var transRsa = tempTr.childNodes[9].innerHTML;
			var is_Async = tempTr.childNodes[10].innerHTML;
			var channelSort=tempTr.childNodes[16].innerHTML;
			var channelflag=tempTr.childNodes[17].innerHTML;
			if(is_Async == "是"){
				$("#is_async").attr("checked",'true');
			}else if(is_Async == "否"){
				$("#is_async").removeAttr("checked");
			}
			var is_AfferentPolno = tempTr.childNodes[11].innerHTML;
			if(is_AfferentPolno == "是"){
				$("#is_afferentpolno").attr("checked",'true');
			}else if(is_Async == "否"){
				$("#is_afferentpolno").removeAttr("checked");
			}
			if(channelflag == "1"){
				$("#is_wxflag").attr("checked",'true');
				$("#channelName_div").attr("readonly","readonly");
				$("#channelName_div").css("background","#ccc");
				$("#deptbtn").attr("disabled","disabled");
			}else {
				$("#is_wxflag").removeAttr("checked");
				$("#channelName_div").removeAttr("readonly");
				$("#deptbtn").removeAttr("disabled");
				$("#channelName_div").css("background","");
			}
			var isThirdPlan= tempTr.childNodes[12].innerHTML;
			var estimateAmout= tempTr.childNodes[15].innerHTML;
			var estimateDes= tempTr.childNodes[16].innerHTML;
			var tbrEmail= tempTr.childNodes[17].innerHTML;
			$("#tbrEmail_div").val(tbrEmail);
			//alert(transType);
			if (transUser == "") {
				transUser = 1;
				/* disabledBtn("channelUserBtn"); */
			} 
			if (transIp == "") {
				transIp = 1;
			 	/* disabledBtn("channelIpBtn"); */
			}
			if (transRsa == "") {
				transRsa = 0;
				/* disabledBtn("channelKeyBtns"); */
			}
			$("#addOrUpdateDiv").OpenDiv();
			$("#channelCode_div").val(channelCode);
			
			$("#channelName_div").val(channelName);
			$("#transType_div").val(transType);
			$("#deptCode_div").val(deptCode);
			$("#deptCname_div").val(deptCname);
			$("#saveChannelInfoBtn").val("更改");
			$("#isThirdPlan_div").val(isThirdPlan);
			$("#channelCode_div").attr("readonly","readonly");
			$("#channelCode_div").css("background","#ccc");
			$("#channelCode_div").unbind("blur");
			$("#channelCode_div_span").css("display","none");
			if(transType == "1"){
				hideChannelInfoRelatedDiv();
				hideChannelInfoRelatedDiv2();
				$("#channelInfoRelated_Key").hide();
				$("#transUSer_div").hide();
				$("#transRSA_div").hide();
				$("#transIP_div").hide();
				
				/* disabledBtn("channelUserBtn"); */
				/* disabledBtn("channelIpBtn"); */
				/* disabledBtn("channelKeyBtns");//lfd */
			}else if(transType == "2"){
				$("#transUSer_div").show();
				$("#transRSA_div").show();
				$("#transIP_div").show();
				$("#transUser_div").val(transUser);
				$("#transIp_div").val(transIp);
				$("#transRsa_div").val(transRsa);
				displayChannelInfoRelatedDiv();
				loadChannelUser();//加载channelUser
				displayChannelIpDiv();
				loadChannelIp();//加载channelIp
				$("#channelInfoRelated_Key").show();
				loadChanelKey();//加载公钥信息
				 if($("#transUser_div").val()==1){
					displayChannelInfoRelatedDiv();
					loadChannelUser();//加载channelUser
				}/*else{
					hideChannelInfoRelatedDiv();
				}   */ 
				if($("#transIp_div").val()==1){
					displayChannelIpDiv();
					loadChannelIp();//加载channelIp
				}/* else{
					hideChannelInfoRelatedDiv2();
				} */
				if($("#transRsa_div").val()==1){
					$("#channelInfoRelated_Key").show();
					loadChanelKey();
				}/* else{
					$("#channelInfoRelated_Key").hide();
				} */
			}
	}
	
	//关闭弹出层
	function closeAddOrUpdateDiv(){
		$("#addOrUpdateDiv").CloseDiv();
		
		//appId_present = '';
		
		$("#deptCode_div").val("");
		$("#deptCname_div").val("");
		$("#addOrUpdateDiv input[type!='button']").val("");
		$("select").val("");
		$("#channelUserTable").find("tbody").remove();
		$("#channelIpTable").find("tbody").remove();
		$("#transType_div").val("1");
		
		hideChannelInfoRelatedDiv();
	}
	//查询秘钥、公钥、合作方公钥
	function loadChanelKey(){
		
		var channelCode_div=$("#channelCode_div").val();
		
		$.ajax({
			url:'<%=path%>/channelManage/loadChannelClientNoInfo?"+new Date().getTime()',
			data:{
				channelCode:channelCode_div
			},
			type:'post',
			dataType:'json',
			async : true,
			success:function(data){
				if($.validate(data))  return;
				//业务处理
				if(null != data){
					$("#PublicKey").val(data.publicKey);
					$("#PrivateKey").val(data.privateKey);
					$("#CooperatePublicKey").val(data.cooperatepublicKey);
					/* /* var buttonStr = "<a href='' onClick='delChannelUser(this);return false'>删除</a>";
					var fieldNames = "publicKey,privateKey,cooperatepublicKey";
					var tableContent = creatTable(fieldNames,data,buttonStr);
					var tableObj = $("#channelKeyTable");
					tableObj.find("tbody").remove();
					tableObj.append(tableContent);  */
				}
			}
		});
	}
	//加载channelUser信息
	function loadChannelUser(){
		var channelCode = $("#channelCode_div").val();

		$.ajax({
			url : "<%=path%>/channelManage/queryChannelUserByFkChannelCode?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:{
				channelCode:channelCode
			},
			dataType:'json',
			success : function(data) {
				if($.validate(data))  return;
				
				//业务处理
				if(null != data){
					var buttonStr = "<a href='' onClick='delChannelUser(this);return false'>删除</a>";
					var fieldNames = "userName,userPassword";
					var tableContent = creatTable(fieldNames,data,buttonStr);
					var tableObj = $("#channelUserTable");
					tableObj.find("tbody").remove();
					tableObj.append(tableContent);
				}
			}
		});
	}
	
	//改变用户密码信息后
	function ChangeUser(){
		var channelCode = $("#channelCode_div").val();

		$.ajax({
			url : "<%=path%>/channelManage/queryChannelUserByFkChannelCode?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:{
				channelCode:channelCode
			},
			dataType:'json',
			success : function(data) {
				if($.validate(data))  return;
				
				var dataLength = data.data.length;
				//alert(dataLength);
				//业务处理
				if(null != data && dataLength>0){
					//confirm("请删除合作伙伴下所有的用户和密码");
					$("#transUser_div").val(0);
					displayChannelInfoRelatedDiv();
				}else{
					$("#transUser_div").val(0);
					hideChannelInfoRelatedDiv();
					return;
				}
			}
		});
	}
	
	//点击"删除(channelUser)"
	function delChannelUser(channelUser){
		var delTr = $(channelUser).parent('td').parent('tr')[0];
		var userName = delTr.childNodes[0].innerHTML;
		
		$.dialog({
			type: "warn",//success,error
			content: "您确定要删除该条记录吗？",
			onOk: function() {
				var fkChannelCode = $("#channelCode_div").val();
				
				$.openLoading();
				//根据联合主键userName和fkChannelCode删除相应的ChannelUser
				$.ajax({
					url : "<%=path%>/channelManage/delChannelUserByChannelUser?"+new Date().getTime(),
					type : 'POST',
					async : true,
					data:{
						fkChannelCode:fkChannelCode,
						userName:userName
					},
					dataType:'json',
					success : function(data) {
						$.closeLoading();
						
						if($.validate(data))  return;
						
						loadChannelUser();
					}
				});
			}
		});
	}
	
	//点击"新增(channelUser)"
	function saveChannelUser(){
		var userName = $.trim($("#userName").val());
		var userPassword = $.trim($("#userPassword").val());
		var fkChannelCode = $("#channelCode_div").val();
		
		if(userName==""){
			$.message("error", "请输入用户名");
			
			return;
		}else if(userName.length > 50){
			$.message("error", "用户名长度不能超过50个字符");
			
			return;
		}else if(userPassword==""){
			$.message("error", "请输入密码");
			
			return;
		}else if(userPassword.length > 50){
			$.message("error", "用户密码长度不能超过50个字符");
			
			return;
		}
		
		$.openLoading();
		$.ajax({
			url : "<%=path%>/channelManage/saveChannelUser?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:{
				userName:userName,
				userPassword:userPassword,
				fkChannelCode:fkChannelCode
			},
			dataType:'json',
			success : function(data) {
				$.closeLoading();
				
				if($.validate(data))  return;
				
				$("#userName").val("");
				$("#userPassword").val("");
				loadChannelUser();
			}
		});
		
	}
	
	//新增channelUser时检查输入的用户名是否已经在该合作伙伴中被占用
	function checkUserName(){
		var userName = $.trim($("#userName").val());
		var channelCode = $("#channelCode_div").val();
		
		if(userName.length == 0){
			return;
		}
		
		$.ajax({
			url : "<%=path%>/channelManage/queryChannelUserByChannelUser?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:{
				fkChannelCode:channelCode,
				userName:userName
			},
			dataType:'json',
			success : function(data) {
				if(data != null && data.result == "fail"){//错误
					$.message("error", "操作错误");
					
				}else if(data != null){//业务处理
					$.message("error", "该用户名在该合作伙伴中已经被占用，请更换");
					
					$("#userName").focus();
				}
			}
		});
	}
	
	//加载channelIp信息
	function loadChannelIp(){
		var channelCode = $("#channelCode_div").val();
		
		$.ajax({
			url : "<%=path%>/channelManage/queryChannelIpByFkChannelCode?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:{
				fkChannelCode:channelCode
			},
			dataType:'json',
			success : function(data) {
				if($.validate(data))  return;
				//业务处理
				if(null != data){
					displayChannelIpDiv();
					var buttonStr = "<a href='' onClick='delChannelIp(this);return false'>删除</a>";
					var fieldNames = "ipDes";
					var tableContent = creatTable(fieldNames,data,buttonStr);
					var tableObj = $("#channelIpTable");
					tableObj.find("tbody").remove();
					tableObj.append(tableContent);
				}
			}
		});
	}
	
	//改变信息
	function ChangeIp(){
		var channelCode = $("#channelCode_div").val();
		
		$.ajax({
			url : "<%=path%>/channelManage/queryChannelIpByFkChannelCode?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:{
				fkChannelCode:channelCode
			},
			dataType:'json',
			success : function(data) {

				var dataLength = data.data.length;
				//alert(dataLength);
				//业务处理
				if(null != data && dataLength>0){
					//confirm("请删除合作伙伴下所有的IP");
					$("#transIp_div").val(0);
					displayChannelIpDiv();
				}else{
					$("#transIp_div").val(0);
					hideChannelInfoRelatedDiv2();
					return;
				}
			}
		});
	}	
	

	//点击"删除(channelIp)"
	function delChannelIp(channelIp){
		var delTr = $(channelIp).parent('td').parent('tr')[0];
		var ipDes = delTr.childNodes[0].innerHTML;

		$.dialog({
			type: "warn",//success,error
			content: "您确定要删除该条记录吗？",
			onOk: function() {
				var fkChannelCode = $("#channelCode_div").val();
				
				$.openLoading();
				//根据联合主键ipDes和fkChannelCode删除相应的ChannelIp
				$.ajax({
					url : "<%=path%>/channelManage/delChannelIpByChannelIp?"+new Date().getTime(),
					type : 'POST', 
					async : true,
					data:{
						fkChannelCode:fkChannelCode,
						ipDes:ipDes
					},
					dataType:'json',
					success : function(data) {
						$.closeLoading();
						
						if($.validate(data))  return;
						
						loadChannelIp();
					}
				});
			}
		});
	}

	//点击"新增(channelIp)"
	var ipFlag = true;
	function saveChannelIp(){
		var ipDes = $.trim($("#ipDes").val());
		var fkChannelCode = $("#channelCode_div").val();
		
		if(ipDes==""){
			$.message("error", "请输入IP");
			
			return;
		} else if(ipDes.length > 50){
			$.message("error", "IP长度不能超过50个字符");
			
			return;
		}
		
		checkIpDes();//检查当前channelInfo中是否已存在输入的IP
		if(ipFlag == false){
			return;
		}
		
		$.openLoading();
		$.ajax({
			url : "<%=path%>/channelManage/saveChannelIp?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:{
				ipDes:ipDes,
				fkChannelCode:fkChannelCode
			},
			dataType:'json',
			success : function(data) {
				$.closeLoading();
				
				if($.validate(data))  return;
				$("#ipDes").val("");
				loadChannelIp();
			}
		});
	}
	//新增秘钥
	function saveChannelKey(){
		
		var publickey=$("#PublicKey").val();
		var privatekey=$("#PrivateKey").val();
		var cooperatepublickey =$("#CooperatePublicKey").val();
		var fkChannelCode = $("#channelCode_div").val();
		var channelKeyBtns=$("#channelKeyBtns").val();
		
		//判断执行操作是否是”新增“
		var channelKeyBtns = $("#channelKeyBtns").val();
		
		var saveOrUpdate;
		if(channelKeyBtns == "新增"){
			saveOrUpdate = "save";
		}
		if(channelKeyBtns == "更改"){
			saveOrUpdate = "update";
		}
		
		
		//alert(channelKeyBtns +"/"+saveOrUpdate);
		if(publickey=="" && privatekey!="" || publickey != "" && privatekey == ""){
			$.message("error", "请同时输入公钥和私钥！");
			return;
		}
		if(cooperatepublickey=="" && publickey=="" && privatekey=="" ){
			$.message("error", "您输入的内容为空，请重新输入！");
			return;
		}
		if(cooperatepublickey.length > 2000 || publickey.length > 2000 || privatekey.length > 2000) {
			$.message("error", "您输入的内容格式不对，请重新输入！");
			return;
		}
		$.openLoading();
		$.ajax({
			url:"<%=path%>/channelManage/saveChannelKey?"+new Date().getTime(),
			data:{
				publickey:publickey,
				privatekey:privatekey,
				cooperatepublickey:cooperatepublickey,
				fkChannelCode: fkChannelCode,
				flag:saveOrUpdate
			},
			Type:'json',
			type : 'POST',
			async : true,
			success:function(data){
				$.closeLoading();
				
				if($.validate(data))  return;
				
				//alert($("#channelKeyBtn").val());
				$("#channelKeyBtns").val("更改");
			}
		});
	}
	
	//新增channelIp时检查输入的IP是否已经在该合作伙伴中存在
	function checkIpDes(){
		var ipDes = $.trim($("#ipDes").val());
		var channelCode = $("#channelCode_div").val();
		
		if(ipDes.length == 0){
			return;
		}
		
		$.ajax({
			url : "<%=path%>/channelManage/queryChannelIpByChannelIp?"+new Date().getTime(),
			type : 'POST',
			async : false,
			data:{
				fkChannelCode:channelCode,
				ipDes:ipDes
			},
			dataType:'json',
			success : function(data) {
				if(data != null && data.result == "fail"){//错误
					$.message("error", "系统错误");
					
				}else if(data != null){//业务处理
					ipFlag = false;
					$.message("error", "该IP在该合作伙伴中已经存在，请更换");
					
					$("#ipDes").focus();
				}else{
					ipFlag = true;
				}
			}
		});
	}
	
	//点击"删除(channelTranstype)"
	function delChannelTranstype(channelTranstype){
		var delTr = $(channelTranstype).parent('td').parent('tr')[0];
		var transtypeId = delTr.childNodes[0].innerHTML;
		
		$.dialog({
			type: "warn",//success,error
			content: "您确定要删除该条记录吗？",
			onOk: function() {
				$.openLoading();
				//根据transtypeId删除相应的channelTranstype
				$.ajax({
					url : "<%=path%>/channelManage/delChannelTranstypeByTranstypeId?"+new Date().getTime(),
					type : 'POST',
					async : true,
					data:{
						transtypeId:transtypeId
					},
					dataType:'json',
					success : function(data) {
						$.closeLoading();
						
						if($.validate(data))  return;
					}
				});
			}
		});
	}
	
	//禁用按钮(传入要禁用的按钮Id)
	function disabledBtn(btnId){
		var disabledBtn = $("#"+btnId+"");
		disabledBtn.attr("disabled","disabled");
		disabledBtn.css("background","gray");
	}
	
	//启用按钮style="background-image: url('');" 
	function enabledBtn(btnId){
		var enabledBtn = $("#"+btnId+"");
		enabledBtn.removeAttr("disabled");
		enabledBtn.css("backgroundImage","url('./images/button_1.png')");
	}
	
	function ChanngRsa(){
		var transRsa_div =$("#transRsa_div").val();
		if(transRsa_div==1){
			/* disabledBtn("channelKeyBtns"); */
			$("#channelKeyBtns").val("新增");
			$("#PublicKey").val("");
			$("#PrivateKey").val("");
			$("#CooperatePublicKey").val("");
			$("#channelInfoRelated_Key").show();
		}else{
			//ChangeRAS();
			var PublicKey =$("#PublicKey").val();
			var PrivateKey =$("#PrivateKey").val();
			var CooperatePublicKey =$("#CooperatePublicKey").val();
			if(PublicKey!=""||PrivateKey!=""||CooperatePublicKey!=""){
				$("#channelInfoRelated_Key").show();
			}else{
				$("#channelInfoRelated_Key").hide();
			}
			
			
		} 
	}
	
	function ChangIP(){
		var transIp_div=$("#transIp_div").val();
		if(transIp_div==0){
			ChangeIp();
		}else{
			/* disabledBtn("channelIpBtn"); */
			displayChannelIpDiv();
		}
	}
	function ChangeUserAndPw(){
		var transUser_div=$("#transUser_div").val();
		if(transUser_div==0){
			ChangeUser();
		}else{
			/* disabledBtn("channelUserBtn"); */
			displayChannelInfoRelatedDiv();
		}
	}
	 
	function selectOne(variable){
		if(variable=="async"){
			var isAfferentPolno = $("#is_afferentpolno");
			if(isAfferentPolno.is(":checked")){
				$("#is_afferentpolno").removeAttr("checked");
			}
		}
		if(variable=="afferentpolno"){
			var isAsync = $("#is_async");
			if(isAsync.is(":checked")){
				$("#is_async").removeAttr("checked");
			}
		}
	}
</script>

  </head>
  
  <body>
  
 	 <div class="current">
           <table class="current_table_1">
             <tbody>
              	<tr class="f2">
	                <td><img src="./images/current_1.jpg"></td>
	                <td class="current_table_1_td">
	                  <img src="images/current_1.png">&nbsp;您现在的位置：&nbsp;
	                  <span style=" color:#136bab; ">合作伙伴管理
	                  	<span style="padding:0 5px; font-weight:bold; line-height:28px;">&gt;</span>合作伙伴配置
	                  </span>
                  	</td>
                 	<td><img src="./images/current_3.jpg"></td>
              	</tr>
           	 </tbody>
           </table>
     </div>
  	
  	<table border="1" id="channelTable" class="table_02" style="height:150px">
  		<tr height="50px">
  			<td colspan="2" align="center">
  				 合作伙伴代码：&nbsp;<input id="channelCode" type="text" value="" class="input_text" />&nbsp;&nbsp;
  				 合作伙伴名称：&nbsp;<input id="channelName" type="text" value="" class="input_text" />&nbsp;&nbsp;
				 <input type="button" id="searchButton" class="input_button_1"  value="查询" onclick="queryChannelInfo(1)"/>
				 <input type="button" id="addButton" class="input_button_1"  value="新增" onclick="addChannelInfo()"/>&nbsp;&nbsp;
				<span style="color: blue;font-weight: bold;font-size: 16px">添加合作伙伴后请配置应用&nbsp;</span> 
			</td>
  		</tr>
  		<tr>
  			<td valign="top">
	  			<div id="channelInfoDIV" style="width:98%;margin:5px" >
			  		<table class="table_02" id="channelInfoTable">
			  		<thead>
		              <tr>
		                  <th style="width:7%">合作伙伴代码</th>
		                  <th style="width:18%">合作伙伴名称</th>
		                  <th style="width:23%">所属机构</th>
		                  <th style="width:5%">合作方式</th>
		                  <th style="width:9%">投保人编码</th>
		                  <th style="width:6%">异步投保</th>
		                  <th style="display:none">接口传入保单号</th>
		                  <th style="display:none">第三方方案</th>
		                  <th style="display:none">唯一标示码</th>
		                  <th style="width:13%">操作</th>
		              </tr>
		              </thead>
		            </table>
	  				 <div id="channelInfoPageDIV"  class="page"></div>
	  			</div>
  			</td>
  		</tr>
  	</table>
  	
  	<%--添加或修改ChanelInfo相关数据弹出层 --%>
  	<div id="addOrUpdateDiv" style="display: none;height: 280px;width: 680px;margin-top: -50px">
  		<div class="table_title_div">
				<table class="table_title" style='width:680px;height: 20px;'>
					<tr>
						<td width="10%"></td>
						<td width="80%" id="interfaceName"></td>
						<td width="10%" align="right"><img src="<%=path %>/images/closedown.gif" alt="关闭"  onclick="closeAddOrUpdateDiv()"/></td>
					</tr>
				</table>
		</div>
		
		<div id="channelRelatedDiv" style="height: 280px;overflow-y: scroll">
	  		<table id="channelRelatedTable" class="table_02" align="center" style="width: 600px">
	   			<tr>
	   				<td>
	   					<div id="channelDiv" style="margin:5px auto;width: 500px">
		   					<table style="border: 1px solid #bbcddb;width: 500px">
		   						<tr>
		   							<td style="border-right: 0px;padding-left:60px;text-align: right;" nowrap="nowrap">合作伙伴代码：</td>
		   							<td style="padding:5px 30px;text-align: left" nowrap="nowrap">
		   								<input type="text" class="input_text" id='channelCode_div' style="width: 250px" /><span id="channelCode_div_span" class="red">*</span>
		   							</td>
		   						</tr>
		   						<tr>
		   							<td style="border-right: 0px;text-align: right;" nowrap="nowrap">合作伙伴名称：</td>
		   							<td style="padding:5px 30px;text-align: left" nowrap="nowrap">
		   								<input type="text" class="input_text" id='channelName_div' style="width: 250px"  value=''/><span class="red">*</span>
		   							</td>
		   						</tr>
		   						<tr>	
		   							<td style="border-right: 0px;text-align: right;" nowrap="nowrap">所属机构：</td>
		   							<td style="padding:5px 30px;text-align: left" nowrap="nowrap">
		   								<input class="input_text" id="deptCname_div" style="width: 250px" readonly="readonly" style="background: #ccc"/>
		   								<input type="button" class="input_button_1" onclick="loadDeptTree()" value="选择" id="deptbtn"/>
		   								<input type="hidden" id="deptCode_div" />
		   							</td>
		   						</tr>
		   						<tr>
		   							<td style="border-right: 0px;text-align: right;" nowrap="nowrap">合作方式：</td>
		   							<td style="padding:5px 30px;text-align: left" nowrap="nowrap">
		   								<select id="transType_div" onchange="channelInfoRelatedDivControl()">
		   									<option value="1">界面出单</option>
		   									<option value="2">系统对接</option>
		   								</select>
		   							</td>
		   						</tr>
		   						<tr style="display: none">
		   							<td style="border-right: 0px;text-align: right;" nowrap="nowrap">异步投保：</td>
		   							<td style="padding:5px 30px;text-align: left" nowrap="nowrap">
										<input type="checkbox" id="is_async" onclick="selectOne('async')"/>&nbsp;&nbsp;&nbsp;
										<span>接口传入保单号：</span>&nbsp;&nbsp;
										<input type="checkbox" id="is_afferentpolno" onclick="selectOne('afferentpolno')"/>
		   								<span>网销专属：</span>&nbsp;&nbsp;
										<input type="checkbox" id="is_wxflag" disabled="disabled"/>
		   							
		   							</td>
		   						</tr>
		   						<tr style="display: none">
		   							<td style="border-right: 0px;text-align: right;" nowrap="nowrap">是否允许第三方传入方案：</td>
		   							<td style="padding:5px 30px;text-align: left" nowrap="nowrap">
										<select id="isThirdPlan_div" >
		   									<option value="0">否</option>
		   									<option value="1">是</option>
		   								</select>
		   							</td>
		   						</tr>
		   						<tr style="display: none">
		   							<td style="border-right: 0px;text-align: right;" nowrap="nowrap">投保人邮箱：</td>
		   							<td style="padding:5px 30px;text-align: left" nowrap="nowrap">
		   								<input type="text" class="input_text" id='tbrEmail_div' style="width: 250px"  value=''/>
		   							</td>
		   						</tr>
		   						<tr id="transUSer_div">
		   							<td style="border-right: 0px;text-align: right;" nowrap="nowrap">用户名密码验证：</td>
		   							<td style="padding:5px 30px;text-align: left" nowrap="nowrap">
		   								<select id="transUser_div" onchange="ChangeUserAndPw()">
		   									<option value="1">是</option>
		   									<option value="0">否</option>
		   								</select>
		   							</td>
		   						</tr>
		   						<tr id="transIP_div" >
		   							<td style="border-right: 0px;text-align: right;" nowrap="nowrap">IP验证：</td>
		   							<td style="padding:5px 30px;text-align: left" nowrap="nowrap">
		   								<select id="transIp_div" onchange="ChangIP()">
		   									<option value="1">是</option>
		   									<option value="0">否</option>
		   								</select>
		   							</td>
		   						</tr>
		   						<tr id="transRSA_div">
		   							<td style="border-right: 0px;text-align: right;" nowrap="nowrap">RSA报文加密加签名：</td>
		   							<td style="padding:5px 30px;text-align: left" nowrap="owrap" >
		   								<select id="transRsa_div" onchange="ChanngRsa()" >
		   									<option value="0">否</option>
		   									<option value="1">是</option>
		   								</select>
		   							</td>
		   						</tr>
		   						<tr id="saveChannelInfoBtnTr">
		   							<td style="border-right: 0px;padding:5px 30px;text-align: center;" nowrap="nowrap" colspan="6" style="text-align: center;padding:8px ;border: 0px">
		   								<input type="button" class="input_button_1" id="saveChannelInfoBtn" onclick="saveOrUpdateChannelInfo()" value="新增"/>
		   							</td>
		   						</tr>
		   						
		   					</table>
		   				</div>
	   				</td>
	   			</tr>
	   			<tbody id="channelInfoRelated_User">
	   			<tr id="channelInfo_UserAndPw">
	   				<td style="width: 600px">
						<div id="channelUserDiv" style="margin:5px auto;width: 500px">
							<table id="channelUserTable" class="table_02" style="width: 500px">
								<thead>
									 <tr>
						                  <th style="width: 300px">用户名</th>
						                  <th style="width: 300px">密码</th>
						                  <th style="width: 200px">操作</th>
						              </tr>
								</thead>
								<tfoot>
									<tr>
										<td style="padding: 10px"><input type="text" id="userName" name="channelUserText" onblur="checkUserName()" value="" class="input_text"/></td>
										<td style="padding: 10px"><input type="text" id="userPassword" name="channelUserText" value="" class="input_text" /></td>
										<td style="padding: 10px"><input class="input_button_1" type="button" id="channelUserBtn" value="新增"  onClick="saveChannelUser()"/></td>
									</tr>
								</tfoot>
							</table>
						</div>
					</td>	
	   			</tr>
	   			</tbody>
	   			<tbody id="channelInfoRelated_Ip">
	   			<tr>
	   				<td style="width: 600px">
						<div id="channelIpDiv" style="margin:5px auto;width: 500px">
							<table id="channelIpTable" class="table_02" style="width: 500px">
								<thead>
									 <tr>
						                  <th style="width: 930px">IP</th>
						                  <th style="width: 200px">操作</th>
						              </tr>
								</thead>
								<tfoot>
									<tr>
										<td style="padding: 10px"><input type="text" id="ipDes" value="" class="input_text" ></td>
										<td style="padding: 10px"><input class="input_button_1" type="button" id="channelIpBtn" value="新增" onClick="saveChannelIp()"/></td>
									</tr>
								</tfoot>
							</table>
						</div>
					</td> 
	   			</tr>
	   			</tbody>
	   			<tbody  id="channelInfoRelated_Key" >
	   			<tr id="channelInfo_Key">
	   				<td>
						<div id="channelKeyDiv" style="margin:5px auto;width: 500px">
							<table id="channelKeyTable" class="table_02" style="width: 500px">
								<thead>
									 <tr>
				                  		<td style="text-align: center; border-right: 0">保司公钥：</td>
				                  		<td style="padding: 8px"><textarea name="reminder" id="PublicKey" cols=""class="textarea_1" style="resize:none;height:80px"></textarea></td>
			              	  	    </tr>
			              	  	    <tr>
				                  		<td style="text-align: center; border-right: 0">保司私钥：</td>
				                  		<td style="padding: 8px"><textarea name="reminder" id="PrivateKey" cols=""class="textarea_1"  style="resize:none;height:80px"></textarea></td>
			              	  	    </tr>
			              	  	    <tr>
				                  		<td style="text-align: center; border-right: 0; ">合作方公钥：</td>
				                  		<td style="padding: 8px"><textarea name="reminder" id="CooperatePublicKey" cols=""class="textarea_1" style="resize:none;height:80px"></textarea></td>
			              	  	    </tr>
								</thead>
								<tfoot>
									<tr>
										<td colspan="2" style="padding: 10px"><input class="input_button_1" type="button" id="channelKeyBtns" value="新增" onClick="saveChannelKey()"/></td>
									</tr>
								</tfoot>
							</table>
						</div>
					</td> 
	   			</tr>
	   			</tbody>
	   			<tbody  id="onSaveAll">
	   				<tr>
						<td colspan="2" style="padding: 10px"><input class="input_button_1" type="button" id="onSaveAllBtn" value="保存" onClick="saveOrUpdateChannelInfo()"/></td>
					</tr>
	   			</tbody>
		   </table>
	   </div>
  	</div>
  	
  	 <%--deptTree(选择所属机构层) --%>
    <div id="deptTreeDiv" style="display: none;width:500px" align="center">
    	<div class="table_title_div">
				<table class="table_title" style='width:100%; height: 20px;'>
					<tr>
						<td width="10%"></td>
						<td width="80%" id="interfaceName"></td>
						<td width="10%" align="right"><img src="<%=path %>/images/closedown.gif" alt="关闭"  onclick="closeDeptTreeDiv()"/></td>
					</tr>
				</table>
		</div>
		
		<div style="height: 300px;overflow-y:auto">
			<ul id="deptTree" class="ztree"></ul>
		</div>
		
		<div style="text-align: center;padding: 5px">
			<input type="button" id="choseDeptBtn" value="确定" onclick="chooseDept()" class="input_button_1"/>&nbsp;&nbsp;&nbsp;
			<input type="button" value="取消" onclick="closeDeptTreeDiv()" class="input_button_1"/>
		</div>
	</div>
	
	
	
	<!--   	生成投保人编码 DIV 默认隐藏-->
  		<div id="createClientNoDiv" style="display:none;width:660px;height:390px;overflow-y:auto;">
		<input type="hidden" id="row_num" name="row_num" value="0"/>
			<div class="table_title_div">
					<table class="table_title" style='width:100%;height: 20px;'>
						<tr>
						<td width="10%"></td>
						<td width="80%" id="interfaceName"></td>
						<td width="10%" align="right"><img src="<%=path %>/images/closedown.gif" alt="关闭"  onclick="closeCurrentDIV('createClientNoDiv')"/></td>
						</tr>
					</table>
			</div>
		<table class="table_02" id="saveAppTable" style="height:70%;width: 95%" align="center" >
			<tr>
				<td style="text-align:right; border-right: 0px; width: 40%;">合作伙伴代码：</td>
				<td colspan="2" style="text-align:left;width: 60%;"><input type="text" id="chCode" style="background-color: #f6f7f9;border:0px;"  readonly="readonly" class="input_text"></td>
			</tr>
			<tr>
				<td style="text-align:right; border-right: 0px; width: 40%;">合作伙伴名称：</td>
				<td colspan="2" style="text-align:left;width: 60%;"><input type="text" id="chName" class="input_text" style="background-color: #f6f7f9;border:0px;"  readonly="readonly" ></td>
			</tr>
			<tr>
				<td style="text-align:right; border-right: 0px; width: 40%;">企业英文名称：</td>
				<td colspan="2" style="text-align:left;width: 60%;">
					<input type="text" id="channelNameEn" class="input_text" maxlength="100">
				</td>
			</tr>
			<tr>
				<td style="text-align:right; border-right: 0px; width: 40%;">法人代表：</td>
				<td colspan="2" style="text-align:left;width: 60%;">
					<input type="text" id="corporateDelegate" class="input_text" maxlength="32">
				</td>
			</tr>
			<tr>
				<td style="text-align:right; border-right: 0px; width: 40%;">合作伙伴证件类型：</td>
				<td colspan="2" style="text-align:left;width: 60%;">
					<select id="idType" class="select_1">
						<option value="0">--------请选择--------</option>
							<c:forEach var="idType" items="${idTypeList}">
			            		<option value="${idType.code}" title="${idType.codeName}">${idType.codeName}</option>
			        		</c:forEach>					
					</select>
				<span class="red">*</span>
				</td>
			</tr>
			<tr>
				<td style="text-align:right; border-right: 0px; width: 40%;">合作伙伴证件号码：</td>
				<td colspan="2" style="text-align:left;width: 60%;">
					<input type="text" id="idNo" class="input_text">
				<span class="red">*</span>
				</td>
			</tr>
			<%-- added by guozizhou@20150409 for bei jing code begin --%>
			<tr>
				<td style="text-align:right; border-right: 0px; width: 40%;">社保登记号：</td>
				<td colspan="2" style="text-align:left;width: 60%;">
				<input type="text" id="socialNo" class="input_text">
				<span id="onlyBeiJingBranch" class="red">*</span>
				</td>
			</tr>
			<tr>
				<td style="text-align:right; border-right:0px;width: 40%;">企业性质：</td>
				<td colspan="2" style="text-align:left;width: 60%;">
				<select id="oneLevelOrgProperty" class="select_1">
					<option value="">--------请选择--------</option>
					<c:forEach var="unitLs" items="${unitLs}">
			            <option value="${unitLs.code}" title="${unitLs.codeName}">${unitLs.codeName}</option>
			        </c:forEach>					
				</select>
				-&nbsp;
				<select id="orgProperty" class="select_1"><option value="">--请选择--</option></select>					
				<span id="onlyBeiJingBranch1" class="red">*</span>
				</td>
			</tr>
			<tr>
				<td style="text-align:right; border-right:0px;width: 40%;">行业类型：</td>
				<td colspan="2" style="text-align:left;width: 60%;">
				<select id="oneLevelTradeCode"  class="select_1">
					<option value="">--------请选择--------</option>
					<c:forEach var="industLs" items="${industLs}">
			            <option value="${industLs.code}" title="${industLs.codeName}">${industLs.codeName}</option>
			        </c:forEach>					
				</select>
				 -&nbsp;
					<select id="tradeCode" class="select_1"><option value="">--请选择--</option></select>
				<span id="onlyBeiJingBranch2" class="red">*</span>
				</td>
			</tr>
			<tr>
				<td style="text-align:right;border-right:0px; width: 30%;">省：<select id="address1" class="select_1"><option value="">------请选择------</option>
					<c:forEach var="provinceLs" items="${provinceLs}">
			            <option value="${provinceLs.areaCode}" title="${provinceLs.areaName}">${provinceLs.areaName}</option>
			        </c:forEach>					
				</select>
				 -
				</td>
				<td colspan="2" style="text-align:left;width: 70%;">市：<select id="address2" class="select_1"><option value="">--请选择--</option></select>
				 -县：<select id="address3" class="select_1"><option value="">--请选择--</option></select>					
				<span id="onlyBeiJingBranch3" class="red">*</span>
				</td>
			</tr>
			<tr>
				<td style="text-align:right; border-right: 0px; width: 40%;">城市区县：</td>
				<td colspan="2" style="text-align:left;width: 60%;">
					<input type="text" id="city" class="input_text" maxlength="50">
				</td>
			</tr>
			<tr>
				<td style="text-align:right; border-right: 0px; width: 40%;">电话：</td>
				<td colspan="2" style="text-align:left;width: 60%;">
					<input type="text" id="telNo" class="input_text" maxlength="16" onKeyUp="clearNoNum(event,this)" onBlur="checkNum(this)">
				</td>
			</tr>
			<tr>
				<td style="text-align:right; border-right: 0px; width: 40%;">传真：</td>
				<td colspan="2" style="text-align:left;width: 60%;">
					<input type="text" id="faxNo" class="input_text" maxlength="16" onKeyUp="clearNoNum(event,this)" onBlur="checkNum(this)">
				</td>
			</tr>
			<tr>
				<td style="text-align:right; border-right: 0px; width: 40%;">邮编：</td>
				<td colspan="2" style="text-align:left;width: 60%;">
					<input type="text" id="postCode" class="input_text" maxlength="8" onKeyUp="clearNoNum(event,this)" onBlur="checkNum(this)">
				</td>
			</tr>
			<tr>
				<td style="text-align:right; border-right: 0px; width: 40%;">通讯地址：</td>
				<td colspan="2" style="text-align:left;width: 60%;">
					<input type="text" id="address" class="input_text" maxlength="100">
				</td>
			</tr>
			<tr>
				<td style="text-align:right; border-right: 0px; width: 40%;">联系人姓名：</td>
				<td colspan="2" style="text-align:left;width: 60%;">
					<input type="text" id="linkManName" class="input_text" maxlength="16">
				</td>
			</tr>
			<tr>
				<td style="text-align:right; border-right: 0px; width: 40%;">联系人证件类别：</td>
				<td colspan="2" style="text-align:left;width: 60%;">
					<select id="linkManCertificateType" class="select_1">
						<option value="">--------请选择--------</option>
							<c:forEach var="linkManIdTypeList" items="${linkManIdTypeLs}">
			            		<option value="${linkManIdTypeList.code}" title="${linkManIdTypeList.codeName}">${linkManIdTypeList.codeName}</option>
			        		</c:forEach>					
					</select>
				</td>
			</tr>
			<tr>
				<td style="text-align:right; border-right: 0px; width: 40%;">联系人证件号码：</td>
				<td colspan="2" style="text-align:left;width: 60%;">
					<input type="text" id="linkManCertificateNo" class="input_text" maxlength="25">
				</td>
			</tr>
			<tr>
				<td style="text-align:right; border-right: 0px; width: 40%;">联系人电话：</td>
				<td colspan="2" style="text-align:left;width: 60%;">
					<input type="text" id="linkManTel" class="input_text" maxlength="16" onKeyUp="clearNoNum(event,this)" onBlur="checkNum(this)">
				</td>
			</tr>
			<tr>
				<td style="text-align:right; border-right: 0px; width: 40%;">联系人通讯地址：</td>
				<td colspan="2" style="text-align:left;width: 60%;">
					<input type="text" id="linkManAddress" class="input_text" maxlength="100">
					<span id="onlyBeiJingBranch4" class="red">*</span>
				</td>
			</tr>
			<tr>
				<td style="text-align:right; border-right: 0px; width: 40%;">联系人邮编：</td>
				<td colspan="2" style="text-align:left;width: 60%;">
					<input type="text" id="linkManPostCode" class="input_text" maxlength="8" onKeyUp="clearNoNum(event,this)" onBlur="checkNum(this)">
				</td>
			</tr>
			<tr>
				<td style="text-align:right; border-right: 0px; width: 40%;">联系人手机：</td>
				<td colspan="2" style="text-align:left;width: 60%;">
					<input type="text" id="linkManMobileNo" class="input_text" maxlength="11" onKeyUp="clearNoNum(event,this)" onBlur="checkNum(this)">
				</td>
			</tr>
		</table>
		<%-- added by guozizhou@20150409 for bei jing code end --%>
		<div style="height:30px;width: 95%" align="center"  >
			<input type="button"  class="input_button_1" value="保存" onClick="createNewClientNo()"/>&nbsp;&nbsp;&nbsp;
			<input type="button" value="取消" onclick="closeCurrentDIV('createClientNoDiv')" class="input_button_1"/>
		</div>
	</div>
  </body>
</html>
